package ru.st.selenium;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;

import org.testng.*;
import org.testng.annotations.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;

import ru.st.selenium.model.Film;

public class AddFilm extends ru.st.selenium.pages.TestBase {
	
	@Test
	public void testAddFilmOK() {
	
		Film film = new Film()
			.setTitle("My test film")
			.setYear("2010");
		
		app.getUserHelper().loginAs(ADMIN);
		app.getFilmHelper().createFilm(film);
		assertTrue(app.getFilmHelper().isCreatedFilm(film));
		app.getUserHelper().logout();
	}
	
	@Test
	public void testAddFilmFailed() {
	
		Film film = new Film()
			.setTitle("My test film");
		
		app.getUserHelper().loginAs(ADMIN);
		app.getFilmHelper().createFilm(film);
		assertTrue(app.getFilmHelper().isNotCreatedFilm());
		app.getUserHelper().logout();
	}
	

//  @Test
//  public void testAddMovieOK() throws Exception {
//	driver.findElement(By.xpath("//a[contains(@href, \"./?go=add\")]")).click();
//		
//	WebElement MovieInformation = waitWebElement(By.cssSelector(".addmovie>h2"));
//	    
//	driver.findElement(By.name("name")).clear();
//	driver.findElement(By.name("name")).sendKeys("My test film");
//	driver.findElement(By.name("aka")).clear();
//	driver.findElement(By.name("aka")).sendKeys("Test also known as...");
//	driver.findElement(By.name("year")).clear();
//	driver.findElement(By.name("year")).sendKeys("2012");
//	driver.findElement(By.id("own_no")).click();
//	driver.findElement(By.name("notes")).clear();
//	driver.findElement(By.name("notes")).sendKeys("Test personal notes...");
//	driver.findElement(By.id("submit")).click();
//	    
//	//Save URL for added film
////	movieAddress = driver.getCurrentUrl();
//		
//	WebElement TitleMovie = waitWebElement(By.xpath("//h2[normalize-space(text())=\"My test film (2012)\"]")); 
//	    
//	driver.findElement(By.cssSelector("h1")).click();
//	    
//	WebElement MoviesList = waitWebElement(By.id("results"));
//  }
}
